package com.swanclouds.redfish.chassis;

import com.google.common.base.Preconditions;
import com.swanclouds.api.Apis;
import com.swanclouds.api.chassis.*;
import com.swanclouds.core.transport.ClientConstants;
import com.swanclouds.model.chassis.Chassis;
import com.swanclouds.model.common.ActionResponse;
import com.swanclouds.redfish.chassis.domain.ChassisModel;
import com.swanclouds.redfish.common.redfish.IndicatorLED;
import com.swanclouds.redfish.internal.BaseChassisService;

/**
 * Author: HuangFuYuHui
 * Title: ChassisServiceImpl
 * Description: TODO
 * Date: 2022/7/18 15:33
 */
public class ChassisServiceImpl extends BaseChassisService implements ChassisService {

    /**
     * 查询服务器系统内的机箱集合资源信息。
     * @return  com.swanclouds.model.chassis.Chassis
     **/
    @Override
    public Chassis get() {
        return get(ChassisModel.class,uri(ClientConstants.PATH_CHASSIS_ID,getChassisId())).execute();
    }

   /**
    * 修改机箱定位指示灯状态。
    * @param  indicatorLED 指示灯属性
    * @return  com.swanclouds.model.common.ActionResponse
    **/
    @Override
    public ActionResponse updateChassisIndicatorLEDStatue(IndicatorLED indicatorLED) {
        Preconditions.checkNotNull(indicatorLED, "indicatorLED is null");
        return  patch(ActionResponse.class,uri(ClientConstants.PATH_CHASSIS_ID,getChassisId()))
                .entity(indicatorLED)
                .execute();
    }

    /**
     * 查询指定服务器机箱的温度和风扇传感器信息服务。
     * @return com.swanclouds.api.chassis.ThermalService
     **/
    @Override
    public ThermalService Thermal() {
        return Apis.get(ThermalService.class);
    }

    /**
     * 查询指定服务器机箱的电压、功率和电源信息服务。
     * @return com.swanclouds.api.chassis.PowerService
     **/
    @Override
    public PowerService Power() {
        return Apis.get(PowerService.class);
    }

    /**
     * 查询网络适配器集合资源信息服务
     * @return com.swanclouds.api.chassis.NetworkAdaptersService
     **/
    @Override
    public NetworkAdaptersService NetworkAdapters() {
        return Apis.get(NetworkAdaptersService.class);
    }

    /**
     * 查询服务器指定驱动器的信息服务。
     * @return com.swanclouds.api.chassis.DrivesService
     **/
    @Override
    public DrivesService Drives() {
        return Apis.get(DrivesService.class);
    }

    /**
     * 查询服务器指定PCIe设备资源信息服务。
     * @return com.swanclouds.api.chassis.PCIeDeviceService
     **/
    @Override
    public PCIeDeviceService PCIeDevices() {
        return Apis.get(PCIeDeviceService.class);
    }

    @Override
    public NetworkPortsService NetworkPorts() {
        return Apis.get(NetworkPortsService.class);
    }
}
